import bus from '../views/common/bus'
//拖动盒子
const dragBoxs = {}

dragBoxs.box =function(box1,box2,box3){
    var oBox=document.getElementById(box1); 
    var oLine = document.getElementById(box2);
    var taskContent = document.getElementById(box3);
    var b='';//声明两个空变量a，b；  
    var a='';  
    var overalDocum = document;
    var Heights;
    oLine.onmousedown=function(ev){ 
        var iEvent=ev||event;  
        var dx=iEvent.clientX;
        var dy=iEvent.clientY;  
        var dw=oBox.offsetWidth;
        var dh=oBox.offsetHeight;
        var disright=oBox.offsetLeft+oBox.offsetWidth;
        var distop=oBox.offsetHeight+oBox.offsetTop; 
        var winHeight = taskContent.offsetHeight;
        if(iEvent.clientY<oBox.offsetTop+210){//同理  
            b='top';  
        }
		if((iEvent.clientY-114)<oBox.offsetHeight+10){//同理  
            b='dow';  
        }  
        document.onmousemove=function(ev){  
            var iEvent=ev||event;
            if(b=='top'){  
                oBox.style.height=dh-(iEvent.clientY-dy)+'px';
                oBox.style.top=distop-oBox.offsetHeight+'px';
                oLine.style.top = distop-oBox.offsetHeight-4+'px';
                Heights =  dh-(iEvent.clientY-dy)+'px';
                if(oBox.offsetTop-2<=10){
                    oLine.style.top='8px';
                    oBox.style.top='10px';
                    oBox.style.height=(winHeight-10)+'px';
                    Heights = (winHeight-10)+'px';
                }
                if(oBox.offsetHeight<=190){  
                    oBox.style.height='190px';
                    oBox.style.top=distop-oBox.offsetHeight+'px';//防止抖动  
                    oLine.style.top=distop-oBox.offsetHeight-4+'px';
                    Heights = '190px';
                }
            }
			if(b=='dow'){
				oBox.style.height=(dh+(iEvent.clientY-dy)+50)+'px';
				oLine.style.top = (dh+(iEvent.clientY-dy)+50)+'px';
				Heights = ((dh+(iEvent.clientY-dy))-10)+'px';
				if(oBox.offsetHeight<=190){  
					oBox.style.height='200px';  
					oLine.style.top='200px';
					Heights = '150px';
				} 
			}
            bus.$emit('HeightInfo', Heights);  
        };  
        document.onmouseup=function(){  
            overalDocum.onmousedown=null;  
            overalDocum.onmousemove=null;  
        };  
        return false;  
    }; 
}

export default dragBoxs;